home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacFormat España 26
/
macformat_26.iso
/
Los 50 mejores
/
Mejoras del sistema
/
Smart Scroll
/
for Developers
/
LScroller.cp example
< prev
next >
Wrap
Text File
|
1996-09-23
|
2KB
|
86 lines
/*
Below is an example of adding "Smart Scrolling" to the PowerPlant LScroller.cp
The SetSmartScrollInfo call gives the Smart Scroll INIT the info it needs
to accurately show which proportion of your document is visible.
note: More examples and a real documentation are coming...
Please email me at Marc@Kagi.com, and I'll help as much as I can
to add this feature to your products!
*/
// ===========================================================================
// LScroller.cp ©1993-1996 Metrowerks Inc. All rights reserved.
// ===========================================================================
//
// A Scroller controls the position of another View and may have a
// horizontal and/or vertical scroll bar
/* <--snip--> */
// ---------------------------------------------------------------------------
// • DrawSelf
// ---------------------------------------------------------------------------
// Draw a Scroller
void
LScroller::DrawSelf()
{
Rect frame; // Scroller has a one pixel border
CalcLocalFrameRect(frame);
::PenNormal();
ApplyForeAndBackColors();
::FrameRect(&frame);
/*msy*/
if (mVerticalBar != nil) {
MoveTo(frame.right - 16, frame.top);
LineTo(frame.right - 16, frame.bottom - 1);
SDimension32 imag;
mScrollingView->GetImageSize(imag);
SDimension16 frm;
mScrollingView->GetFrameSize(frm);
SetSmartScrollInfo (mVerticalBar->GetMacControl(), (long) frm.height ,
(long) imag.height);
}
if (mHorizontalBar != nil) {
MoveTo(frame.left, frame.bottom - 16);
LineTo(frame.right - 1, frame.bottom - 16);
SDimension32 imag;
mScrollingView->GetImageSize(imag);
SDimension16 frm;
mScrollingView->GetFrameSize(frm);
SetSmartScrollInfo (mHorizontalBar->GetMacControl(), (long) frm.width ,
(long) imag.width );
}
// When inactive, ScrollBars are hidden. Just outline
// the ScrollBar locations with one pixel borders.
if (!IsActive()) {
if (mVerticalBar != nil) {
mVerticalBar->CalcPortFrameRect(frame);
PortToLocalPoint(topLeft(frame));
PortToLocalPoint(botRight(frame));
::FrameRect(&frame);
::InsetRect(&frame, 1, 1);
::EraseRect(&frame);
}
if (mHorizontalBar != nil) {
mHorizontalBar->CalcPortFrameRect(frame);
PortToLocalPoint(topLeft(frame));
PortToLocalPoint(botRight(frame));
::FrameRect(&frame);
::InsetRect(&frame, 1, 1);
::EraseRect(&frame);
}
}
}
/* <--snip--> */